<template>
	<view class="evaluate">
		<view v-for="(item,index) in data.orderItemVoList" :key="index">
			<view class="topInfo">
				<image :src="item.productPic" mode="widthFix"></image>
				<view class="rightInfo">
					<view class="title">
						{{item.productName}}
					</view>
					<view class="type">
						{{item.productAttr}}
					</view>
				</view>
			</view>
			<view class="write">
				<textarea maxlength="200" v-model="item.value" placeholder="写下你的评价吧,最多200字噢~" />
				<view class="addBox">
					<view class="imgList">
						<image src="../../static/images/add_image.png" mode="scaleToFill"></image>
						<text class="closeBtn">×</text>
					</view>
					<view class="addImg">
						<image src="../../static/images/add_image.png" mode="scaleToFill"></image>
						<text>添加图片</text>
					</view>
					<view class="addVideo">
						<image src="../../static/images/add_video.png" mode="scaleToFill"></image>
						<text>添加视频</text>
					</view>
				</view>
			</view>
			
		</view>
			
			<view class="submitBtn" @tap="submit">
				提交
			</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				value: "",
				data:{}
			}
		},
		onLoad(e) {
			this.data = JSON.parse(decodeURIComponent(e.data))
			console.log(this.data)
		},
		methods:{
			submit(){
				let data={
					 "createRequests": [],
				}
				for (let i = 0; i < this.data.orderItemVoList.length; i++) {
					if(this.data.orderItemVoList[i].value == undefined){
						uni.showToast({
							title:"您还有商品没有评论哦~",
							icon:"none"
						})
						return false;
					}
					data.createRequests.push({
						  "comment": this.data.orderItemVoList[i].value,
						  "commentParentId": "0",
						  "img": this.data.orderItemVoList[i].productPic,
						  "orderId": this.data.orderId,
						  "productAttr": this.data.orderItemVoList[i].productAttr,
						  "productId": this.data.orderItemVoList[i].productId,
						  "productName": this.data.orderItemVoList[i].productName,
						  "userId": this.data.userId,
						  "userLogo": uni.getStorageSync('userLogo'),
						  "userName": uni.getStorageSync('nickName'),
						  "userType": 1,
						  "video": ""
					})
				}
				this.$http.post('/api/v1.0/product/comment/insertList',data,res=>{
					console.log(res.data)
					if(res.data.status == '000000'){
						uni.redirectTo({
							url:"../result/result?type=evaluate"
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">
	.evaluate{
		background-color: #f2f2f2;
		min-height: 100vh;
		box-sizing: border-box;
		padding-top: 20upx;
		padding-bottom: 140upx;
		position: relative;
		.topInfo{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			box-sizing: border-box;
			padding: 30upx 28upx 18upx;
			background-color: #fff;
			image{
				width: 140upx;
				height: 140upx;
				margin-right: 20upx;
			}
			.rightInfo{
				.title{
					width: 536upx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					font-size: 28upx;
				}
				.type{
					display: -webkit-box;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					word-wrap: break-word;
					-webkit-line-clamp:2;
					-webkit-box-orient:vertical;
					width:327upx;
					font-size: 22upx;
				}
			}
			
		}
		.write{
			background-color: #fff;
			margin-top: 10upx;
			padding: 20upx;
			margin-bottom: 20upx;
			textarea{
				width: 100%;
				height: 200upx;
			}
			.addBox{
				padding-left: 28upx;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				background-color: #fff;
				&>view{
					width: 156upx;
					height: 156upx;
					text-align: center;
					border: 1upx solid #E6E6E6;
					padding-top: 31upx;
					box-sizing: border-box;
					margin-right: 20upx;
					image{
						width: 58upx;
						height: 58upx;
					}
					text{
						color: #E6E6E6;
						font-size: 23upx;
						display: block;
					}
				}
				.imgList{
					position: relative;
					image{
						width: 100%;
						height: 100%;
					}
					.closeBtn{
						position: absolute;
						width: 40upx;
						height: 40upx;
						color: #fff;
						top: -10upx;
						right: -10upx;
						background-color: #666;
						border-radius: 50%;
						font-size: 26upx;
						line-height: 40upx;
						text-align: center;
					}
				}
			}
		}
		.submitBtn{
			width: 694upx;
			height: 100upx;
			background:linear-gradient(0deg,rgba(232,39,27,1),rgba(250,94,52,1));
			position: fixed;
			bottom: 30upx;
			left: 28upx;
			text-align: center;
			line-height: 95upx;
			font-size: 36upx;
			font-weight: bold;
			color: #fff;
			
		}
	}
</style>
